package motiveai.tests;

import com.jme3.app.SimpleApplication;
import com.jme3.renderer.RenderManager;
import motiveai.components.EntityAgent;
import motiveai.components.MotiveAI;
import motiveai.factors.EnvironmentDefinition;
import motiveai.factors.FactorBoolean;
import motiveai.learn.LearningType;

/**
 * test
 * @author oxplay
 */
public class Test1_StressTest extends SimpleApplication {

    private MotiveAI ai;
    private EnvironmentDefinition env;

    public static void main(String[] args) {
        Test1_StressTest app = new Test1_StressTest();
        app.start();
    }

    private void addAgents(int num) {
        for (int i = 0; i < num; i++) {
            EntityAgent agent = new EntityAgent();
            ai.addAgent(agent);
        }
    }

    @Override
    public void simpleInitApp() {
        env = new EnvironmentDefinition();
        env.setFactorDefinition("isEnemyNear", new FactorBoolean(false, false, 4));
        env.setFactorDefinition("needARest", new FactorBoolean(false, false, 1));
        ai = new MotiveAI<EntityAgent>(env, LearningType.HIGH_PRECISE, 100);
        ai.registerBehaviour(Test1KillEnemy.class);
        ai.registerBehaviour(Test1Idle.class);
        addAgents(1000);
        ai.addSensor(new Test1Sensor());
        ai.setUpdateRate(0);
        stateManager.attach(ai);
    }

    @Override
    public void simpleUpdate(float tpf) {
    }

    @Override
    public void simpleRender(RenderManager rm) {
        //TODO: add render code
    }
}
